﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CachePoolManager
{
    private static readonly CachePools defaultPool = new CachePools();
    
    /// <summary>
    /// 获取对象
    /// </summary>
    /// <param name="prefab"></param>
    /// <param name="parent"></param>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public static T GetOne<T>(GameObject prefab,Transform parent)where T:IPoolObject
    {
        return defaultPool.GetOne<T>(prefab, parent);
    }
    
    /// <summary>
    /// 回收对象
    /// </summary>
    /// <param name="instance"></param>
    /// <typeparam name="T"></typeparam>
    public static void RecycleOne<T>(T instance) where T : IPoolObject
    {
        defaultPool.RecycleOne<T>(instance);
    }

    /// <summary>
    /// 移除实例
    /// </summary>
    /// <param name="instance"></param>
    /// <typeparam name="T"></typeparam>
    public static void Remove<T>(T instance) where T : IPoolObject
    {
        defaultPool.Remove(instance);
    }
    
    /// <summary>
    /// 销毁所有
    /// </summary>
    public static void DestroyAll()
    {
        defaultPool.DestroyAll();
    }

    /// <summary>
    /// 释放未使用资源
    /// </summary>
    public void UnloadUnused()
    {
        defaultPool.UnloadUnused();
    }

    /// <summary>
    /// 销毁池子
    /// </summary>
    /// <param name="prefab"></param>
    public static void DestroyPool(GameObject prefab)
    {
        defaultPool.DestroyPool(prefab);
    }
}
